
package jgf;

import java.io.Serializable;

/**
 * This class implements an attribute. It is intended to be used in vectors of attributes for arcs and/or nodes.
 * @author Marcos Garcia Ortega <a href="mailto:thiamath@gmail.com">&lt;thiamath@gmail.com&gt;</a>
 */
public class Attribute implements Serializable{

	// <editor-fold defaultstate="collapsed" desc="Fields">
	/** The name of the attribute. */
	private String name;
	/** The value of the attribute. */
	private int value;
	// </editor-fold>

	//////////////////////////
	// Attribute management //
	//////////////////////////

	// <editor-fold defaultstate="collapsed" desc="Constructors">
	/**
	 * Constructor that creates an empty atribute without label
	 * or value.
	 */
	protected Attribute() {
		this("", 0);
	}

	/**
	 * Creates an attribute with the given name and value.
	 * @param name The name of the attribute.
	 * @param value Its value.
	 */
	public Attribute(String name, int value) {
		this.name = name;
		this.value = value;
	}
	// </editor-fold>

	// <editor-fold defaultstate="collapsed" desc="Getters">
	/**
	 * Gets the name of the attribute.
	 * @return A String with the name of the attribute.
	 */
	public String getName() {
		return name;
	}

	/**
	 * Gets the value of the attribute.
	 * @return An Integer with the value of the attribute.
	 */
	public int getValue() {
		return value;
	}
	// </editor-fold>

	// <editor-fold defaultstate="collapsed" desc="Setters">
	/**
	 * Sets the name of the attribute.
	 * @param newName The new name for the attribute.
	 */
	public void setName(String newName) {
		this.name = newName;
	}

	/**
	 * Sets the value of the attribute.
	 * @param value The new value of the attribute.
	 */
	public void setValue(int newValue) {
		this.value = newValue;
	}
	// </editor-fold>

	@Override
	public Attribute clone(){
		return new Attribute(name, value);
	}
}
